package command;

import ihm.Ihm;
import controller.Controller;
import materiel.Clavier;
import materiel.MouseWheel;


public class CommandLireMateriel implements Command {

	private Clavier clavier;
	private MouseWheel wheel;
	private Ihm ihm;
	private Controller controller;
	
	public CommandLireMateriel(Clavier clavier, MouseWheel wheel, Ihm ihm, Controller controller){
		this.clavier=clavier;
		this.wheel=wheel;
		this.ihm=ihm;
		this.controller=controller;
	}
	
	/**
	 * Execute la commande
	 */
	public void execute() {
		for(int i=0;i<4;i++){
			if(clavier.buttonPressed(i)){
				if(i==0)
					controller.start();
				else if(i==1)
					controller.stop();
				else if(i==2)
					controller.incMeasure();
				else
					controller.decMeasure();
			}
		}
		if(wheel.getCurrent()!=wheel.getNewValue()){
			wheel.setNewValue(wheel.getCurrent());
			ihm.notifyObserver();
		}
	}

}
